@extends('layouts.admin')
@section('content')
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="{{url('admin/index')}}">首页</a> &raquo; <a href="#">导航列表</a>
    </div>
    <!--面包屑导航 结束-->
    <!--搜索结果页面 列表 开始-->
    <form action="#" method="post">
        <div class="result_wrap">
            <!--快捷导航 开始-->
            <div class="result_content">
                <div class="short_wrap">
                    <a href="{{url('admin/navs/create')}}"><i class="fa fa-plus"></i>新增导航</a>
                    <a href="{{url('admin/index')}}"><i class="fa fa-recycle"></i>首页</a>
                    <a href="#"><i class="fa fa-refresh"></i>更新排序</a>
                </div>
            </div>
            <!--快捷导航 结束-->
        </div>

        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
                    <tr>
                        <th class="tc">排序</th>
                        <th class="tc">ID</th>
                        <th>名称</th>
                        <th>别名</th>
                        <th>标题</th>
                        <th>链接</th>
                        <th>发布时间</th>
                        <th>操作</th>
                    </tr>
                    @foreach($data as $v)
                        <tr>
                            <td class="tc">
                                <input type="text" style="width: 40px" onchange="changeOrder('{{$v->navs_id}}',this)"  value="{{$v->navs_order}}">
                            </td>
                            <td class="tc">{{$v->navs_id}}</td>
                            <td>
                                <a href="#">{{$v->navs_name}}</a>
                            </td>
                            <td>
                                <a href="#">{{$v->navs_eng}}</a>
                            </td>
                            <td>
                                <a href="#">{{$v->navs_title}}</a>
                            </td>
                            <td>{{$v->navs_url}}</td>
                            <td>{{date('Y-m-d H:i:s',$v->add_time)}}</td>
                            <td>
                                <a href="{{url('admin/navs/'.$v->navs_id.'/edit')}}">修改</a>
                                <a href="javascript:void (0)" onclick="delnavs('{{$v->navs_id}}')">删除</a>
                            </td>
                        </tr>
                        @endforeach
                </table>
                <div class="page_list">
                    {{$data->links()}}
                </div>
            </div>
        </div>
    </form>
    <!--搜索结果页面 列表 结束-->

<style>
    .result_content ul li span {
        font-size: 15px;
        padding: 6px 12px;
    }
</style>

@endsection
<script>
    function changeOrder(cate_id,obj){
        $.post("{{url('admin/navs/changeorder')}}",{'_token':'{{csrf_token()}}','cate_id':cate_id,'num':$(obj).val()},function(data){

            if(data.status==1){
                layer.msg('修改成功', {icon: 1});
                location.reload()
            }else{
                layer.msg('修改失败', {icon: 1});
            }

        })
    }
    function delnavs(id){
        layer.confirm('确定删除？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("{{url('admin/navs')}}/"+id,{'_token':'{{csrf_token()}}','id':id,'_method':'delete'},function(data) {
                if(data.status==1){
                    layer.msg(data.msg, {icon: 1});
                    setTimeout('location.reload()',2000)
                }else{
                    layer.msg(data.msg, {icon: 1});
//                    setTimeout('location.reload()',2000)
                }
            })

        });

    }
</script>